package org.jground.rx.ui.zk;

import org.apache.commons.logging.Log;import org.apache.commons.logging.LogFactory;
import org.jground.rx.IRXObject;
import org.jground.rx.ui.IUIAttribute;
import org.jground.util.L;
import org.zkoss.zk.ui.Component;

public class UIEditPanel extends UIViewPanel {

    private static Log logger = LogFactory.getLog(UIEditPanel.class);

    // private bool allMandatoryAttributesOK;

    public UIEditPanel(UIFrame uiFrame, String moid) {
        super(uiFrame, moid);
        //init();
    }

    protected void init() {
        L.debug(logger, "Start Init of UIEditPanel", this.moClass.getMoid());
        rxPanel = moClass.getEditRXPanel();
        createPages();
    }

    public void setData(IRXObject moDataObject) {
        super.setData(moDataObject);
        // bool allMandatoryAttributesOK = true;
        for (IUIAttribute<Component,UIFrame> uiAttribute : uiAttributes) {
            // allMandatoryAttributesOK = allMandatoryAttributesOK &
            uiAttribute.checkMandatory();
        }
    }

    public IRXObject getData() {
        if (moDataObject != null) {
            for (IUIAttribute<Component,UIFrame> uiAttribute : uiAttributes) {
                uiAttribute.updateData();
            }
        }
        return moDataObject;
    }

}
